package server.handler.friendHandler;

import com.alibaba.fastjson.JSONObject;
import common.EnvelopeMessage;
import common.bodies.FriendShipBody;
import server.dao.FriendDao;
import server.handler.SimpleHandler;
import server.session.Session;

public class FriendRequestHandler implements SimpleHandler {
    @Override
    public void handle(EnvelopeMessage msg, Session session) {
        JSONObject body = msg.getBody();
        Integer user1Id = body.getInteger("fromId");
        String  user1Name = body.getString("fromName");
        Integer user2Id = body.getInteger("toFriendId");
        String user2Name = body.getString("toFriendName");
        FriendShipBody   newFriendRequest =   new FriendShipBody(user1Id,user1Name,user2Id,user2Name,0);
        new FriendDao().updateFriendShip(newFriendRequest);
        }


}
